<style>
    [data-level-zero] {
        top: 0;
        left: 0;
        right: 0;
        bottom: 2px;
        color: #FFF;
        display: flex;
        position: absolute;
        font-size: 20px;
        font-weight: bold;
        align-items: center;
        border-radius: 3px;
        letter-spacing: 1px;
        justify-content: center;
        background: rgba(0, 0, 0, 0.5);
        text-shadow: #666 1px 1px 3px;
    }

    .min-input {
        width: 50px;
        border: 1px solid rgba(0, 0, 0, 0.3);
        font-size: 12px;
        padding-left: 15px;
        border-radius: 3px;
    }

    .card-bgimg .uploadimage {
        width: 150px;
        background-size: 100% 100%;
    }
</style>

<form action="{:sysuri()}" class="layui-form layui-card" data-auto="true" method="post">
    <div class="layui-card-body padding-left-40">

        <div class="layui-form-item">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-xs6">
                    <span class="help-label"><b>等级图标</b>( 建议上传尺寸为 400x400 的图片或同比例图片 )</span>
                    <div class="relative block layui-textarea help-images">
                        <input type="hidden" name="cover" value='{$vo.cover|default=""}'>
                        <script>$('[name="cover"]').uploadOneImage()</script>
                    </div>
                </div>
                <div class="layui-col-xs6 card-bgimg">
                    <span class="help-label"><b>卡片背景</b>( 建议上传尺寸为 650x330 的图片或同比例图片)</span>
                    <div class="relative block layui-textarea help-images">
                        <input type="hidden" name="cardbg" value='{$vo.cardbg|default=""}'>
                        <script>$('[name="cardbg"]').uploadOneImage()</script>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item flex">
            <div class="flex-1">
                <span class="help-label label-required-prev"><b>等级序号</b>Level Serial</span>
                <select class="layui-select" name="number" lay-filter="number">
                    {for start="0" end="$max" name="i"}{if isset($vo.number) and $vo.number eq $i}
                    <option selected value="{$i}">当前 VIP {$vo.number} 等级</option>
                    {else}
                    <option value="{$i}">设置 VIP {$i} 等级</option>
                    {/if}{/for}
                </select>
            </div>
            <label class="flex-3 margin-left-15 relative">
                <span class="help-label label-required-prev"><b>等级名称</b>Level Name</span>
                <input class="layui-input" name="name" placeholder="请输入等级名称" required value="{$vo.name|default=''}">
            </label>
        </div>

        <div class="layui-form-item">
            <span class="help-label label-required-prev"><b>团队计数</b>Team Count</span>
            {empty name='vo.upgrade_team'}{assign name='vo.upgrade_team' value='1'}{/empty}
            <div class="layui-textarea help-checks">
                {foreach ['不参与团队计数','参与团队计数'] as $k => $v}
                <label class="think-radio">
                    {if isset($vo.upgrade_team) and $vo.upgrade_team eq $k}
                    <input name="upgrade_team" type="radio" value="{$k}" checked lay-ignore> {$v}
                    {else}
                    <input name="upgrade_team" type="radio" value="{$k}" lay-ignore> {$v}
                    {/if}
                </label>
                {/foreach}
            </div>
        </div>

        <div class="layui-form-item">
            <span class="help-label label-required-prev"><b>升级规则</b>Upgrade Type</span>
            {empty name='vo.upgrade_type'}{assign name='vo.upgrade_type' value='1'}{/empty}
            <div class="layui-textarea help-checks">
                {foreach ['达成任意条件','达成全部条件'] as $k => $v}
                <label class="think-radio">
                    {if isset($vo.upgrade_type) and $vo.upgrade_type eq $k}
                    <input name="upgrade_type" type="radio" value="{$k}" lay-ignore checked> {$v}
                    {else}
                    <input name="upgrade_type" type="radio" value="{$k}" lay-ignore> {$v}
                    {/if}
                </label>
                {/foreach}
            </div>
        </div>

        <div class="layui-form-item">
            <span class="help-label label-required-prev"><b>升级条件</b>Upgrade Rules</span>
            <div class="font-s13 layui-bg-gray relative">
                <div>
                    <label class="think-checkbox notselect">
                        {if isset($vo.enter_vip_status) and $vo.enter_vip_status eq 1}
                        ① <input lay-ignore name="enter_vip_status" type="checkbox" value="1" checked>开启
                        {else}
                        ① <input lay-ignore name="enter_vip_status" type="checkbox" value="1">开启
                        {/if}
                        需要 <span class="color-blue">购买入会礼包</span> 达成升级；
                    </label>
                </div>
                <div>
                    <label class="think-checkbox notselect">
                        {if isset($vo.teams_direct_status) and $vo.teams_direct_status eq 1}
                        ② <input lay-ignore name="teams_direct_status" type="checkbox" value="1" checked>开启
                        {else}
                        ② <input lay-ignore name="teams_direct_status" type="checkbox" value="1">开启
                        {/if}
                        <span class="color-blue">直推团队</span> 升级，<span class="color-blue">直推团队</span> 达到
                        <input class="inline-block text-center min-input" name="teams_direct_number" data-blur-number="0" min="0" type="number" value="{$vo.teams_direct_number|default='0'}">
                        人；
                    </label>
                </div>
                <div>
                    <label class="think-checkbox notselect">
                        {if isset($vo.teams_indirect_status) and $vo.teams_indirect_status eq 1}
                        ③ <input lay-ignore name="teams_indirect_status" type="checkbox" value="1" checked>开启
                        {else}
                        ③ <input lay-ignore name="teams_indirect_status" type="checkbox" value="1">开启
                        {/if}
                        <span class="color-blue">间接团队</span> 升级，<span class="color-blue">间接团队</span> 达到
                        <input class="inline-block text-center min-input" name="teams_indirect_number" data-blur-number="0" min="0" type="number" value="{$vo.teams_indirect_number|default='0'}">
                        人；
                    </label>
                </div>
                <div>
                    <label class="think-checkbox notselect">
                        {if isset($vo.teams_users_status) and $vo.teams_users_status eq 1}
                        ④ <input lay-ignore name="teams_users_status" type="checkbox" value="1" checked>开启
                        {else}
                        ④ <input lay-ignore name="teams_users_status" type="checkbox" value="1">开启
                        {/if}
                        <span class="color-blue">团队总数</span> 升级，<span class="color-blue">团队总数</span> 达到
                        <input class="inline-block text-center min-input" name="teams_users_number" data-blur-number="0" min="0" type="number" value="{$vo.teams_users_number|default='0'}">
                        人；
                    </label>
                </div>
                <div>
                    <label class="think-checkbox notselect">
                        {if isset($vo.order_amount_status) and $vo.order_amount_status eq 1}
                        ⑤ <input lay-ignore name="order_amount_status" type="checkbox" value="1" checked>开启
                        {else}
                        ⑤ <input lay-ignore name="order_amount_status" type="checkbox" value="1">开启
                        {/if}
                        <span class="color-blue">订单总额</span> 升级，<span class="color-blue">订单总额</span> 达到
                        <input class="inline-block text-center min-input" name="order_amount_number" data-blur-number="2" min="0" type="number" value="{$vo.order_amount_number|default='0'}">
                        元；
                    </label>
                </div>
                <div data-level-zero class="layui-hide notselect">默认等级，无需配置升级规则</div>
            </div>
        </div>

        <label class="layui-form-item">
            <span class="help-label"><b>权益描述</b>Privilege Description</span>
            <textarea class="layui-textarea" name="remark" placeholder="请输入权益描述">{$vo.remark|default=''}</textarea>
        </label>

    </div>

    <div class="hr-line-dashed"></div>
    {if isset($vo.id)}<input name='id' type='hidden' value='{$vo.id}'>{/if}
    {if isset($vo.number)}<input name='old_number' type='hidden' value='{$vo.number}'>{/if}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" data-close data-confirm="确定要取消编辑吗？" type='button'>取消编辑</button>
    </div>

</form>

<script>
    $(function () {
        let $elem = $('[data-level-zero]');
        layui.form.on('select(number)', apply);
        apply({value: parseInt("{$vo.number|default=0}")});

        function apply(data) {
            data.value > 0 ? $elem.addClass('layui-hide') : $elem.removeClass('layui-hide');
        }
    });
</script>
